package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.utils.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/admin/common")
@Slf4j
public class CommonController {

    @PostMapping("/upload")
    public Result<String> upload(MultipartFile file) throws IOException {
        // 使用阿里oos上传图片
        AliOSSUtils aliOSSUtils = new AliOSSUtils();
        String url = aliOSSUtils.upload(file);

        //返回网络地址
        return Result.success(url);

    }

}
